<template>
	<div>
		<el-tabs v-model="activeName" @tab-click="handleTabChange">
			<el-tab-pane v-for="(item, index) in tabsList" :key="index" :label="item.label" :name="item.value"> </el-tab-pane>

			<div class="content-card">
				<html-label :title="activeLabelTitle">
				</html-label>

				<component class="pd10" v-if="!loading" :is="whickComm[activeName]" :soleKey="`dpServiceOrgHome-${nowRowData.creditCode}`" @refresh="handleRefresh" :nowRowData="nowRowData"></component>
			</div>
		</el-tabs>
	</div>
</template>

<script setup lang="ts">
import BaseDetail from './BaseDetail/index.vue'
import Extend from './Extend/index.vue'
import apiMod from '@/apiMod'
import { useCommonStore } from '@/stores/common'

const { setLoading } = useCommonStore()

const tabsList = [
	{ label: '基础信息', value: 'BaseDetail' },
	{ label: '扩展数据', value: 'Extend' },
]

const whickComm = {
	BaseDetail,
	Extend,
}
const activeName = ref('BaseDetail')
type Props = {
	nowRowData?: any
}

const loading = ref(false)

const props = withDefaults(defineProps<Props>(), {})
const baseData = ref({})
provide('nowRowData', baseData)

const emit = defineEmits(['refresh', 'rechange'])
const activeLabelTitle = ref('基本信息')

const getInitData = () => {
  loading.value = true 
  setLoading(true)
	apiMod.view_dpServiceOrgHomeFile_all({creditCode: props.nowRowData.creditCode,}).then((res) => {
    const data = res.data ||{}
    baseData.value = data
    loading.value = false
    setLoading(false)
	})
}
const handleTabChange = (tab) => {
	activeLabelTitle.value = tab.props.label
}

const handleRefresh = () => {
	emit('refresh')
}

onMounted(()=> {
  getInitData()
})
</script>

<style scoped></style>
